<template>
  <div>
    <a-row :gutter="16">
      <a-col :md="24" :lg="16">
        <a-form ref="FormRef" layout="vertical" :model="FormState" :rules="FormRule">
          <a-form-item label="昵称" name="nickname">
            <a-input
              v-model:value="FormState.nickname"
              placeholder="给自己起个名字"
              name="nickname"
            />
          </a-form-item>
          <a-form-item label="个人签名" name="slogan">
            <a-textarea
              v-model:value="FormState.slogan"
              rows="4"
              placeholder="你想写点什么"
              name="slogan"
            />
          </a-form-item>
          <a-form-item>
            <a-button type="primary" html-type="submit" :loading="ConfirmLoading" @click="OnSubmit">
              提交
            </a-button>
            <a-button style="margin-left: 8px" @click="OnReset">重置</a-button>
          </a-form-item>
        </a-form>
      </a-col>
      <a-col :md="24" :lg="8" :style="{ minHeight: '180px' }">
        <div class="ant-upload-preview" @click="$refs.modal.edit(1)">
          <!-- <a-icon type="cloud-upload-o" class="upload-icon" />
          <div class="mask">
            <a-icon type="plus" />
          </div>
          <img src="" /> -->
        </div>
      </a-col>
    </a-row>
  </div>
</template>

<script lang="ts">
import { IconFont } from '@/components/iconfont'
import { defineComponent, reactive, toRefs, onMounted, ref, toRaw } from 'vue'
import { Row, Col } from 'ant-design-vue'

export default defineComponent({
  name: 'BaseSettings',
  components: {
    IconFont,
    [Row.name]: Row,
    [Col.name]: Col
  },
  setup() {
    const FormRef = ref()
    const state = reactive({
      ConfirmLoading: false,
      selectedKeys: [],
      openKeys: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 3 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    })
    const FormState = reactive({
      nickname: '',
      slogan: '',
      email: ''
    })
    const FormRule = {
      nickname: [{ required: true, message: '请填写昵称', trigger: ['blur', 'change'] }],
      slogan: [{ required: true, message: '请填写口号', trigger: ['blur', 'change'] }],
      email: [{ required: true, message: '请填写邮箱', trigger: ['blur', 'change'] }]
    }
    onMounted(() => {
      getDataList()
    })
    const tabChange = () => {
      getDataList()
    }
    const onOpenChange = (openKeys) => {
      state.openKeys = openKeys
    }

    function getDataList() {}
    const OnSubmit = () => {
      FormRef.value
        .validate()
        .then(() => {
          console.log(toRaw(FormState))
        })
        .catch(() => {
          return false
        })
    }
    const OnReset = () => {
      FormRef.value.resetFields()
    }
    return {
      ...toRefs(state),
      FormRef,
      onOpenChange,
      FormState,
      FormRule,
      tabChange,
      OnSubmit,
      OnReset,
      getDataList
    }
  }
})
</script>

<style lang="scss" scoped>
.account-settings-info-main {
  width: 100%;
  display: flex;
  height: 100%;
  overflow: auto;

  &.mobile {
    display: block;

    .account-settings-info-left {
      border-right: unset;
      border-bottom: 1px solid #e8e8e8;
      width: 100%;
      height: 50px;
      overflow-x: auto;
      overflow-y: scroll;
    }
    .account-settings-info-right {
      padding: 20px 40px;
    }
  }

  .account-settings-info-left {
    border-right: 1px solid #e8e8e8;
    width: 224px;
  }

  .account-settings-info-right {
    flex: 1 1;
    padding: 8px 40px;

    .account-settings-info-title {
      color: rgba(0, 0, 0, 0.85);
      font-size: 20px;
      font-weight: 500;
      line-height: 28px;
      margin-bottom: 12px;
    }
    .account-settings-info-view {
      padding-top: 12px;
    }
  }
}
</style>
